package cn.edu.cug.cs.gtl.apis.ui.projecttree;

import cn.edu.cug.cs.gtl.apis.ui.AbstractApplication;
import cn.edu.cug.cs.gtl.apis.ui.tree.Tree;
import cn.edu.cug.cs.gtl.apis.ui.tree.TreeSelectionListener;
import cn.edu.cug.cs.gtl.protos.Layer;
import cn.edu.cug.cs.gtl.protos.Map;
import cn.edu.cug.cs.gtl.protos.Project;

public class ProjectTreeSelectionListener extends TreeSelectionListener {
    public ProjectTreeSelectionListener(Tree tree, AbstractApplication theApp) {
        super(tree, theApp);
    }

    @Override
    protected void objectChanged(Object obj) {
        Object refObject = this.theTree.getCurrentReferencedObject();
        if(refObject instanceof Project){
            //Do Nothing
        }
        else if(refObject instanceof Map){
            this.theApp.setCurrentMap((Map) refObject);
        }
        else if(refObject instanceof Layer){
            //Table Panel切换显示当前图层的数据表
            this.theApp.setCurrentLayer((Layer) refObject);
            this.theApp.getMainFrame().getTablePanel().reset();
        }
        else{

        }
    }
}
